﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using WPFMitsuControls;

namespace MangaEplision
{
    /// <summary>
    /// Interaction logic for MangaViewer.xaml
    /// </summary>
    public partial class MangaViewer : Window
    {
        private Book book = null;
        public MangaViewer(Book bk)
        {
            InitializeComponent();
            book = bk;
            foreach (Image i in bk.Pages)
            {
                BookPage bp = new BookPage();
                bp.Content = i;
                BookCntrl.Items.Add(bp);
            }
            //PreviousbTN.IsEnabled = false;
            this.Closing += new System.ComponentModel.CancelEventHandler(MangaViewer_Closing);
        }

        void MangaViewer_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            
            book.Pages.Clear();
            book = null;
                
        }
        int c = 0;
        private void PreviousbTN_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                BookCntrl.AnimateToPreviousPage(true, 700);
            }
            catch (Exception) { }
        }

        private void NextBtn_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                BookCntrl.CurrentPage = BookCurrentPage.RightSheet;
                //BookCntrl.MoveToNextPage();
                BookCntrl.AnimateToNextPage(true, 700);
            }
            catch (Exception) { }
        }
    }
}
